package br.furb.models;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "usuarios")
@NamedQueries({
		@NamedQuery(name = "Usuario.searchAsc", query = "select u from Usuario u order by u.usuarioId asc"),
		@NamedQuery(name = "Usuario.searchDesc", query = "select u from Usuario u order by u.usuarioId desc") })
public class Usuario {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "usuario_id", nullable = false, unique = true)
	private Integer usuarioId;
	@Column(length = 50)
	private String nome;
	@OneToMany(mappedBy = "usuario")
	private List<Midia> midias;

	public void setUsuarioId(Integer usuarioId) {
		this.usuarioId = usuarioId;
	}

	public Integer getUsuarioId() {
		return usuarioId;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public List<Midia> getMidias() {
		return midias;
	}
	
	public void setMidias(List<Midia> midias) {
		this.midias = midias;
	}
	
	public void addMidia(Midia midia){
		midias.add(midia);
	}
}
